using System.IO;
using NHibernate;
using NHibernate.Cfg;
using Rhino.Commons;
using System.Diagnostics;
using System.Reflection;

namespace WineCellar.Core.NHibernate
{
    public class CaptureConfiguration : INHibernateInitializationAware
    {
        public static Configuration cfg;

        #region INHibernateInitializationAware Members

        public void BeforeInitialization()
        {
        }

        #endregion
        
        
        public void Configured(Configuration cfg)
        {
            string lucentLocation = Path.Combine(System.Environment.CurrentDirectory, @"LuceneStore\Index");
            cfg.SetProperty("hibernate.search.default.directory_provider",
                                           "NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search");
            cfg.SetProperty("hibernate.search.default.indexBase", lucentLocation);

        }

        public void Initialized(Configuration cfg, ISessionFactory sessionFactory)
        {
            CaptureConfiguration.cfg = cfg;
        }
    }
}